import { Component, OnInit } from "@angular/core";
import { FormsModule } from "@angular/forms";


@Component({
  selector: "pzl-place",
  templateUrl: "./place.component.html",
  styleUrls: ["./place.component.scss"]
})
export class PlaceComponent implements OnInit {
  _comStatus:number;//组件当前的状态。  初始化-激活（左右）-完成状态；
  fromobj: place; //出发
  topobj: place; //到达
  constructor() {
    this.fromobj = { name: "常州", placeholder: "常州", isfocus: false };
    this.topobj = { name: "北京", placeholder: "北京", isfocus: false };
    this._comStatus = 0;//初始化状态
  }

  ngOnInit() { }
  handleblur(obj:place) {
    console.log('失去焦点');
    if (obj.name == '') {
      obj.name = obj.placeholder;
    }
  }
  handlefocus(plc:place,event: any) {
    console.log(event);
    if (this._comStatus == 0) {
      event.target.blur();
      
      this._comStatus++;
    }
    plc.name = "";
  }
}
interface place {
  name: string;
  placeholder: string;
  isfocus: boolean;
}
